@{
    // delete comment
    // INIT VARS
    string ErrorMessage="";
    string SuccessMessage="";

    // Get USER ID
    var  userId = WebSecurity.CurrentUserId;
    // GET COMMENT ID
    var CommentId = UrlData[0];
    // set view
    var view ="~/Actions/Admin/ListAllComments";
    
    // check if registered user is the auhor of the article where the comment comes from
    // if not redirect
    
    var Comment = Blog.DataObject.GetCommentByArticleIdAndUserId(userId.ToString(),CommentId);
    if(String.IsNullOrEmpty(Comment.id.ToString())){
    // user cannot delete comment as the article where the comment was posted doesnt belong to the current user
    Response.Redirect("~/");
    }
    // if comment is published , unpublish else publish 
    if(Comment.published<=0){
        // publish
        var publishComment = Blog.DataObject.PublishComment(Comment.id.ToString());
        // test if request is successfull
        if(publishComment>0){
            SuccessMessage = "Comment successfully published";
        }else{
            ErrorMessage = "Comment not published";
        }
    }else{
        // unpublish
        var unpublishComment = Blog.DataObject.UnPublishComment(Comment.id.ToString());
        // test if request is successfull
        if(unpublishComment>0){
            SuccessMessage = "Comment successfully unpublished";
        }else{
            ErrorMessage = "Comment not unpublished";
        }
    }
    // Redirect to view
    Response.Redirect(@Href(view,new{SuccessMessage = SuccessMessage , ErrorMessage = ErrorMessage }));
}